package educationaladministrationsystem.CSM.Controller.Root;

import educationaladministrationsystem.Class.Faculties;
import educationaladministrationsystem.Result.Result;
import educationaladministrationsystem.CSM.Mapper.Service.Root.RootFacultiesFacultiesService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

//院系数据传送层
@Slf4j
@RestController
@RequestMapping("/Root/Faculties")
public class RootFacultiesController {
    @Autowired
    private RootFacultiesFacultiesService rootFacultiesService;

    //    增加院系
    @PostMapping("/addNewFaculties")
    public Result addNewFaculties(@RequestBody Faculties faculties) {
        return Result.success(rootFacultiesService.addNewFaculties(faculties));
    }

    //    分页获取数据
    @GetMapping("/pageShow")
    public Result getFacultiesInformation(@RequestParam Integer page, @RequestParam Integer pageNumber) {
        return Result.success(rootFacultiesService.getFacultiesInformation(page, pageNumber));
    }

    //    更新院系信息
    @PutMapping("/updateFaculties")
    public Result updateFacultiesInformation(@RequestBody Faculties faculties, @RequestParam String oldFacultiesId) {
        return Result.success(rootFacultiesService.updateFacultiesInformation(faculties, oldFacultiesId));
    }

    //    删除院系信息
    @PutMapping("/deleteInformation")
    public Result deleteInformation(@RequestParam Integer deleteId) {
        return Result.success(rootFacultiesService.deleteInformation(deleteId));
    }

    //    获取最大页数
    @GetMapping("/allPage")
    public Result getAllPage(@RequestParam Integer pageNumber) {
        return Result.success(rootFacultiesService.getAllPage(pageNumber));
    }
}
